<%@page import="org.edu.model.*"%>
<%@ page language='java' contentType='text/html; charset=utf-8'
	pageEncoding='utf-8'%>

<%@ include file='../common/base.jsp'%>
<%
	String u=((User)session.getAttribute("user")).getAccount();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>

<meta http-equiv='X-UA-Compatible' content='IE=10' />
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
<title>在职人员</title>
<link href='${path }/dist/css/bootstrap.min.css' rel='stylesheet' />
<link href='${path }/dist/css/Buttom.css' rel='stylesheet' />
<link
	href="http://cdn.bootcss.com/font-awesome/4.2.0/css/font-awesome.min.css"
	rel="stylesheet">
<link href="${path }/dist/css/flat-ui.css" rel="stylesheet">
<%-- 属flat-ui--%>
<style type="text/css">
table tr .choose {
	width: 50px;
}

table tr .choose>td.aiignm {
	vertical-align: middle;
}
ul li span>b{
	color:  #428bca;
}
ul li span{
	color:  #777;
}
</style>

</head>
<body>
	<div class="panel panel-default">
		<div class="panel-heading" style="background: none;">
			<span class="fui-tag"></span> <span>${emp.empname }</span>

			<button type="button"
				class="buttons button-caution button-rounded button-tiny"
				style="float: right; margin-right: 60px;"
				onclick="window.location.href='${path}/newuser/signup'">创建用户</button>
			<button type="button"
				class="buttons button-caution button-rounded button-tiny"
				style="float: right; margin-right: 10px;"
				onclick="window.location.href='${path}/role/allrole'">管理角色</button>

		</div>
		<div class="panel-body" style="padding: 0px;">
			<div class="table-responsive">
				<table class="table table-bordered table-hover">
					<thead>
						<tr>
							<th class="choose">选择</th>
							<th>用户名</th>
							<th>真实姓名</th>
							<th>部门</th>
							<th>排班</th>
							<th>角色</th>
							<th>管理范围</th>
							<th>在线时间</th>
							<th>离线时间</th>
							<th>操作</th>

						</tr>
					</thead>
					<tbody>

						<c:forEach var="wal" items="${result.currentList}"
							varStatus="status">
							<tr class="choose">
								<td><input type="checkbox" name="check" value="${wal.account}" /></td>
								<td>${wal.account}</td>
								<td>${wal.fullname }</td>
								<td>${emp.empname }</td>
								<td>${wal.scheduling }</td>
								<td>${wal.roleid }</td>
								<td>${wal.range }</td>
								<td id="online_${wal.account}">${wal.online }<%-- <fmt:formatDate value="" type="both" />--%></td>
								<td>${wal.offtime }</td>
								<td style="padding: 3px;"><a
									href="#" onclick="emptyTime('${wal.account}')">清空时长</a><br /> <a href="#">编辑</a></td>
							</tr>
						</c:forEach>
						<%--
						<tr class="choose">
							<td ><input type="checkbox" name="check"/></td>
							<td>ssss</td>
							<td>啊啊</td>
							<td >财务经理</td>
							<td>正常排班</td>
							<td>部门经理</td>
							<td>本部门</td>
							<td>从未在线</td>
							<td>从未登录</td>
							<td style="padding: 3px;"><a href="#">清空时长</a><br /> <a href="#">编辑</a></td>
						</tr>
						 --%>
					</tbody>
				</table>
				<ul class="list-group">
					<li class="list-group-item">
						<%-- 
						<ul class="pagination-plain" style="margin-bottom: 0px;">
							<li class="previous"><a href="#">Previous</a></li>
							<li class="active"><a href="#">1</a></li>
							<li><a href="#">2</a></li>
							<li><a href="#">3</a></li>
							<li class="next"><a href="#">Newer</a></li>
						</ul>
						--%>
						<button type="button"
							class="buttons button-primary button-rounded button-tiny"
							onclick="window.location.href='${path}/emp/emp?empid=${emp.empno }&currentPage=${result.per}'">上一页</button>
						<button type="button"
							class="buttons button-primary button-rounded button-tiny"
							onclick="window.location.href='${path}/emp/emp?empid=${emp.empno }&currentPage=${result.next}'">下一页</button>
						<span>[第<b>${result.currentPage==null?1: result.currentPage}</b>页]/</span>
						<span>[共<b>${result.allPage==null?1:result.allPage }</b>页]</span>&nbsp;&nbsp;
						<span>[每页10条]/</span> <span>[共<b>${result.listsize==null?0:result.listsize }</b>条]</span>
					</li>
					<li class="list-group-item"><input type="checkbox"
						id="check_select" onclick="check_all(this,'check')" />全选 <input
						type="checkbox" value="" id="check_invert"
						onclick="uncheck_all('check')" />反选 <a href="#"
						style="margin-left: 5px;">删除所选用户</a> <a href="#"
						style="margin-left: 5px;" id="checkcleantime">清空所选在线用户时长</a> 
						<a href="#" style="margin-left: 5px;" id="checkpassref">还原所选用户密码默认密码</a></li>
				</ul>
			</div>
		</div>
	</div>

	<script src='${path }/dist/js/jquery.min.js'></script>
	<script src='${path }/dist/js/bootstrap.min.js'></script>

	<script type="text/javascript">
	<!--
		function check_all(obj, cName) {
			var checkboxs = document.getElementsByName(cName);
			// alert(obj.checked);
			if (obj.checked) {
				for (var i = 0; i < checkboxs.length; i++) {
					//alert(checkboxs[i].checked);
					checkboxs[i].checked = true;
					//alert(checkboxs[i].value);
				}
			} else {
				for (var i = 0; i < checkboxs.length; i++) {
					//alert(checkboxs[i].checked);
					checkboxs[i].checked = false;
				}
			}
		}
		function uncheck_all(cName) {
			var checkboxs = document.getElementsByName(cName);
			//alert(document.getElementById("check_select").checked);

			for (var i = 0; i < checkboxs.length; i++) {
				//alert(checkboxs[i].checked);
				checkboxs[i].checked = checkboxs[i].checked ? false : true;
			}
			if (chenk_allseleclt(cName))
				document.getElementById("check_select").checked = true;
			else
				document.getElementById("check_select").checked = false;
		}
		function chenk_allseleclt(cName) {

			var checkboxs = document.getElementsByName(cName);
			for (var i = 0; i < checkboxs.length; i++) {
				//alert(checkboxs[i].checked);
				if (!checkboxs[i].checked) {
					return false;
				}
			}
			return true;
		}
		//获取选中的帐号
		function checkacc(cName) {
			
			var acc = "";
			var checkboxs = document.getElementsByName(cName);
			for (var i = 0; i < checkboxs.length; i++) {
				
				if(checkboxs[i].checked==true){
					acc += checkboxs[i].value;
					if (i < checkboxs.length - 1) {
						acc += ";";
					}
				}
			}
			return acc;
		}
		function emptyTime(account) {
			$.ajax({
				async : false,
				cache : false,
				type : 'POST',
				dataType : "html",
				url : '${path}/emp/emptytime?accountarray=' + account,
				success : function(data) {
					var strs= new Array();
					strs=account.split(";"); //字符分割 
					for (i=0;i<strs.length ;i++ ) { 
						//alert(strs[i]); //分割后的字符输出 
						$("#online_"+strs[i]).html("从未上线");
					} 
				},
				error : function() {
					//失败
					alert("失败");
				}
			});
		}
		
		function passDefault(account) {
			$.ajax({
				async : false,
				cache : false,
				type : 'POST',
				dataType : "html",
				url : '${path}/emp/passdefault?accountarray=' + account,
				success : function(data) {
					alert("成功");
				},
				error : function() {
					//失败
					alert("失败");
				}
			});
		}
		$(document).ready(function(){
			$("#checkcleantime").bind("click",function(){
				var acc=checkacc("check");
				if(acc.length>0){
					emptyTime(acc);
				}else{alert("请选择一个帐号");}
			});
			$("#checkpassref").bind("click",function(){
				var acc=checkacc("check");
				if(acc.length>0){
					passDefault(acc);
				}else{alert("请选择一个帐号");}
			});
		});
	//-->
	</script>
</body>
</html>